#!/usr/bin/env bash

install_rpm() {
    sudo yum update
    sudo yum install \
        --assumeyes \
        https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
    sudo yum install \
        --assumeyes \
        neovim
}

install_deb() {
    sudo apt update
    sudo apt install \
        --no-install-recommends \
        --yes \
        neovim
}

version() {
    # neovim version
    echo -e "\033[32m"
    echo -e "=============================="
    echo -e "  Neovim: v$(nvim --version | head -n 1 | awk '{print $2}' | sed 's/^v//')"
    echo -e "=============================="
    echo -e "\033[0m"
}

main() {
    if grep -qi "anolis" /etc/os-release; then
        install_rpm
    else
        install_deb
    fi
    version
}

main
